package com.toubutu.audio.controller;

import com.toubutu.audio.entity.VideoCategory;
import com.toubutu.audio.service.VideoCategoryService;
import com.toubutu.common.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戒躁
 * @since 2024-01-10
 */
@RestController
@RequestMapping("/category")
public class VideoCategoryController {
    @Resource
    private VideoCategoryService categoryService;

    @GetMapping("/parent/list")
    public Result<List<VideoCategory>> getAllParentCategoryList(){
        return Result.ok(categoryService.getAllParentCategoryList());
    }
    @GetMapping("/children/{parentId}")
    public Result<List<VideoCategory>> getChildrenCategoryList(@PathVariable Integer parentId){
        return Result.ok(categoryService.getChildrenCategoryList(parentId));
    }
}
